const tags = {
    name: "movies",
    description: "电影管理模块",
};
// 用来描述数据结构
const schemas = {
    // 获取当前页面的条件的数据结构
    ArrayOfMovies: {
        properties: {
            total: {
                type: "number",
                description: "总数",
            },
            maxPage: {
                type: "number",
                description: "总页数",
            },
            rows: {
                type: "array",
                description: "电影当页数据",
                items: {
                    $ref: "#/components/schemas/movies",
                },
            },
        },
    },
    // 每条电影数据的结构
    movies: {
        properties: {
            _id: {
                type: "string",
                description: "唯一标识",
            },
            cname: {
                type: "string",
                description: "电影名",
            },
            ename: {
                type: "string",
                description: "电影英文名",
            },
            type: {
                type: "string",
                description: "电影的类型",
            },
            area: {
                type: "string",
                description: "首映地区",
            },
            poster: {
                type: "string",
                description: "电影海报",
            },
            time: {
                type: "number",
                description: "电影时长",
            },
            upDate: {
                type: "string",
                description: "上映时间",
            },
            score: {
                type: "number",
                description: "电影评分",
            },
            count: {
                type: "string",
                description: "电影票房",
            },
            intro: {
                type: "string",
                description: "剧情简介",
            },
            isClassic: {
                type: "boolean",
                description: "是否是经典",
            },
            director: {
                type: "string",
                description: "导演",
            },
            actor: {
                type: "string",
                description: "演员",
            },
            imgs: {
                type: "string",
                description: "剧集图片",
            },

        },
    },
    // 新增电影的数据结构
    moviesAdd: {
        properties: {
            _id: {
                type: "string",
                description: "唯一标识",
            },
            cname: {
                type: "string",
                description: "电影名",
            },
            ename: {
                type: "string",
                description: "电影英文名",
            },
            type: {
                type: "string",
                description: "电影的类型",
            },
            area: {
                type: "string",
                description: "首映地区",
            },
            poster: {
                type: "string",
                description: "电影海报",
            },
            time: {
                type: "number",
                description: "电影时长",
            },
            upDate: {
                type: "string",
                description: "上映时间",
            },
            score: {
                type: "number",
                description: "电影评分",
            },
            count: {
                type: "string",
                description: "电影票房",
            },
            intro: {
                type: "string",
                description: "剧情简介",
            },
            isClassic: {
                type: "boolean",
                description: "是否是经典",
            },
            director: {
                type: "string",
                description: "导演",
            },
            actor: {
                type: "string",
                description: "演员",
            },
            imgs: {
                type: "string",
                description: "剧集图片",
            },

        },
    },
    // 修改电影结构
    moviesRevise: {
        properties: {
            _id: {
                type: "string",
                description: "唯一标识",
            },
            cname: {
                type: "string",
                description: "电影名",
            },
            ename: {
                type: "string",
                description: "电影英文名",
            },
            type: {
                type: "string",
                description: "电影的类型",
            },
            area: {
                type: "string",
                description: "首映地区",
            },
            poster: {
                type: "string",
                description: "电影海报",
            },
            time: {
                type: "number",
                description: "电影时长",
            },
            upDate: {
                type: "string",
                description: "上映时间",
            },
            score: {
                type: "number",
                description: "电影评分",
            },
            count: {
                type: "string",
                description: "电影票房",
            },
            intro: {
                type: "string",
                description: "剧情简介",
            },
            isClassic: {
                type: "boolean",
                description: "是否是经典",
            },
            director: {
                type: "string",
                description: "导演",
            },
            actor: {
                type: "string",
                description: "演员",
            },
            imgs: {
                type: "string",
                description: "剧集图片",
            },

        },
    },
    // 新增电影返回值结构
    addReturn: {
        properties: {
            status: {
                type: "boolean",
                description: "是否成功状态,true为成功，false为失败",
            },
        },
    },

    // 删除电影结构
    removeMovies: {
        properties: {
            _id: {
                type: "string",
                description: "id值",
            }
        }
    },
    // 删除电影返回值结构
    removeReturn: {
        properties: {
            status: {
                type: "boolean",
                description: "是否成功状态,true为成功，false为失败",
            },
        },
    },

    // 删除电影返回值结构
    reviseReturn: {
        properties: {
            status: {
                type: "boolean",
                description: "是否成功状态,true为成功，false为失败",
            },
        },

    }
};
// 配置
const paths = {
    "/movies": {
        get: {
            tags: ["movies"],
            summary: "电影信息",
            description: "获取当页的电影数据",//具体描述
            consumes: ["application/json"],
            // parameters 请求参数
            parameters: [
                {
                    name: "curPage",
                    in: "query",//get类型的参数在query中获取
                    schema: {
                        type: "integer",//integer 整数
                        default: 1,
                    },
                    required: true, //必填
                    description: "当前页码",
                },
                {
                    name: "eachPage",
                    in: "query",
                    schema: {
                        type: "integer",
                        default: 1,
                    },
                    required: true,
                    description: "每页条数",
                },
            ],
            // 响应
            responses: {
                200: {
                    description: "操作成功",
                    content: {
                        "application/json": {
                            schema: {
                                $ref: "#/components/schemas/ArrayOfMovies",//拿到对应的数据结构
                            },
                        },
                    },
                },
                404: {
                    description: "找不到资源",
                },
            },
        },
    },
    "/movies/add": {
        post: {
            tags: ["movies"],//属于哪一个功能模块
            summary: "新增电影信息",//属于哪一个功能模块
            description: "新增电影信息,需要输入电影的对应参数",// 具体描述
            consumes: ["application/json"], //请求的数据类型 JSON
            // 请求参数
            requestBody: {
                // 必填
                required: true,
                //内容(具体参数)
                content: {
                    "application/json": {
                        //参数的结构
                        schema: {
                            $ref: "#/components/schemas/moviesAdd",
                        },
                        // example 例子
                        example: {
                            id:"614ee6aedc364c19d8bee169",
                            cname: "蜡笔小新",
                            ename: 'クレヨンしんちゃん',
                            type: '动画',
                            area: "日本",
                            time: 24,
                            upDate: "1996-3-14",
                            score: "8.8",
                            count: "暂无",
                            intro: "暂无",
                            isClassic: false,
                            director: "本乡满",
                            actor: "矢岛晶子",
                        },
                    },
                },
            },
            // 响应
            responses: {
             
                200: {
                    description: "操作成功",
                    content: {
                        "application/json": {
                            schema: {
                                $ref: "#/components/schemas/addReturn",
                            },
                        },
                    },
                },
                404: {
                    description: "找不到资源",
                },
            },
        },
    },
    "/movies/remove": {
        post: {
            tags: ["movies"], //属于哪一个功能模块
            summary: "删除电影",
            // 具体描述
            description: "这是一个删除电影功能，需传入电影相对应的参数",
            consumes: ["application/json"], //请求的数据类型 JSON
            requestBody: {    //请求参数
                required: true, //必填
                content: {  //内容(具体参数)
                    "application/json": {
                        schema: {//参数的结构
                            $ref: "#/components/schemas/removeMovies",
                        },
                        // example 例子
                        example: {
                            _id: "614d673f0037f4201c411b1f",
                        },
                    },
                },
            },
            // 响应
            responses: {
             
                200: {
                    description: "操作成功",
                    content: {
                        "application/json": {
                            schema: {
                                $ref: "#/components/schemas/removeReturn",
                            },
                        },
                    },
                },
                404: {
                    description: "找不到资源",
                },
            },
        },
    },
    "/movies/revise": {
        put: {
            tags: ["movies"], //属于哪一个功能模块
            summary: "修改电影",
            // 具体描述
            description: "这是一个修改电影功能，需传入电影相对应的参数",
            consumes: ["application/json"], //请求的数据类型 JSON
            requestBody: {    //请求参数
                required: true, //必填
                content: {  //内容(具体参数)
                    "application/json": {
                        schema: {//参数的结构
                            $ref: "#/components/schemas/moviesRevise",
                        },
                        // example 例子
                        example: {
                            _id: "614ee6aedc364c19d8bee169",
                            cname: "乌啦啦",
                            ename: 'クレヨンしんちゃん',
                            type: '吃播',
                            area: "中国",
                            time: 30,
                            upDate: "2021-3-14",
                            score: "8.8",
                            count: "暂无",
                            intro: "暂无",
                            isClassic: false,
                            director: "乌啦啦",
                            actor: "乌啦啦",
                          },
                    },
                },
            },
            // 响应
            responses: {
                200: {
                    description: "操作成功",
                    content: {
                        "application/json": {
                            schema: {
                                $ref: "#/components/schemas/changeReturn",
                            },
                        },
                    },
                },
                404: {
                    description: "找不到资源",
                },
            },
        },
    }

};

module.exports = { tags, schemas, paths }
